new Vue({
    el: '#app',
    data() {
      return {
        form: {
          page: 1,			//页数
          limit: 10,			//每页数据条数
          Enterprise_Info_SerialNumber:$.cookie('enterprise'),
          Article_Name:'',
          Dealer_Name:'',
          Dealer_Article_SerialNumber:'',
        },
        tableData: [],		//表格数据
        total: 1,
      }
    },
    mounted() {
      this.getList(this.form)
    },
    methods: {
      onSerach() {//查询方法
        this.form.page = 1
        this.getList(this.form)
      },
      handleSizeChange(val) {
        this.form.page = 1;
        this.form.limit = val;
        this.getList(this.form)
      },
      handleCurrentChange(val) {
        this.form.page = val;
        this.getList(this.form)
      },
      getList(data) {     //换页方法
        let _this = this
        $.ajax({
          type: 'POST',
          url: DomainName + "/getDealerArticleConfigAll?token=" + $.cookie('token'),
          data,
          complete: function (XMLHttpRequest) {
            _this.loading = false
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          },
          success: function (Result) {
            console.log(Result.tableData);
            _this.tableData = Result.tableData;
            _this.total = Number(Result.limit)
          },
          dataType: "json"
        });
      },
      Add() {
        window.location.href = './Add.html'
      },
      Edit(Dealer_Article_Config_SerialNumber) {
        sessionStorage.setItem("Dealer_Article_Config_SerialNumber", Dealer_Article_Config_SerialNumber)
        window.location.href = './Edit.html?Dealer_Article_Config_SerialNumber=' + Dealer_Article_Config_SerialNumber
      },
      deletMember(Category_SerialNumber) {
        this.$confirm('此操作将删除该类别, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          this.delete(Category_SerialNumber);
          this.getList(this.form);
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      delete(Category_SerialNumber) {
        const _this = this
        $.ajax({
          url: DomainName + '/ShopCategory_Original',
          type: 'GET',
          async: false,
          data: { action: "jQueryAjax" },
          success: function (res) {
            console.log(res);
            for (let i = 0; i < res.length; i++) {
              if (res[i].Category_SerialNumber == Category_SerialNumber) {
                res[i].Row_Status = '1'
                _this.detel = res[i];
              }
            }
          },
          complete: function (XMLHttpRequest) {
            _this.loading = false
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          }
        })
        let data = { Data: JSON.stringify({ Modify: { category: [_this.detel] } }) };
        $.ajax({
          url: DomainName + '/GoodsFileEdit',
          type: 'POST',
          async: false,
          data: data,
          error: function () {
            _this.$message.error("删除失败，请稍后再试")
          },
          complete: function (XMLHttpRequest) {
            _this.loading = false
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          }
        })
      },
    },
  })